"""自定义工具类"""
import functools

from flask import session, current_app

from info.models import User


def do_index_class(index):
    if index == 1:
        return "first"
    elif index == 2:
        return "second"
    elif index == 3:
        return "third"
    return ""

#
# def user_login_data(fun):
#     """
#     functools.wraps 则可以将原函数对象的指定属性复制给包装函数对象,
#     默认有 __module__、__name__、__doc__,
#     :param fun:
#     :return:
#     """
#
#     @functools.wraps(fun)
#     def inner_fun(*args, **kwargs):
#         user_id = session.get("user_id", None)
#         user = None  # type:User
#         if user_id:
#             try:
#                 user = User.query.get(user_id)
#             except Exception as e:
#                 current_app.logger.error(e)
#         g.user = user
#         return fun(*args, **kwargs)
#
#     return inner_fun
